package com.zysc.processflow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zysc.processflow.entity.Brand;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: Mr.Liuyijiang
 * @Description:
 * @Date Created in 2022-06-04 19:40
 * @Modified By:
 */
@Repository
public interface BrandMapper extends BaseMapper<Brand> {

    @Insert("insert into `tb_category_brand` (`category_id`, `brand_id`) values(#{cid},#{bid});")
    void insertCategoryAndBrand(@Param("cid") Long cid, @Param("bid") Long id);

    @Delete("delete from `tb_category_brand` where brand_id = #{bid};")
    void deleteCategoryAndBrand(@Param("bid") Long id);

    @Select("select * from        tb_brand a INNER JOIN tb_category_brand b on a.id=b.brand_id          where b.category_id=#{cid}")
    List<Brand> selectBrandsByCid(Long cid);
}
